package com.hxkj.controller.analyze;

import com.hxkj.domain.po.Article;
import com.hxkj.domain.po.Column;
import com.hxkj.domain.po.ColumnArticleTree;
import com.hxkj.domain.po.Tags;
import com.hxkj.service.analyze.ColumnArticleService;
import com.hxkj.service.article.ColumnService;
import com.platform.common.domain.result.ResultPageStruct;
import com.platform.common.domain.to.PageTo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * @ClassName ColumnArticleController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/7/2 15:02
 * @Version 1.0
 */
@RestController
@RequestMapping("/columnArticle")
public class ColumnArticleController {

    @Autowired
    private ColumnArticleService columnArticleService;

    @Autowired
    private ColumnService columnService;

    /**
     * @Description getColumnArticle 获取分类文章列表
     **/
    @RequestMapping(value = "/getArticleList")
    public Callable<ColumnArticleTree> getColumnArticle(@ModelAttribute Column column, @ModelAttribute PageTo pageParam) throws Exception {
        return () -> columnArticleService.getColumnArticle(column == null ? new Column():column,pageParam);
    }

    /**
     * @Description getColumnList 获取文章分类下的文章列表
     **/
    @RequestMapping(value = "/getlist", method = RequestMethod.POST)
    public Callable<ResultPageStruct<Article>> getColumnList(@ModelAttribute Column column, @ModelAttribute PageTo pageParam) throws Exception{
        return () -> columnService.getColumnList(column,pageParam);
    }


    /**
     * @Description getTagsArticle 获取tags标签关联的文章列表
     **/
    @RequestMapping(value = "/gettaglist")
    public Callable<ResultPageStruct<Article>> getTagsArticle(@ModelAttribute Tags tags, @ModelAttribute PageTo pageParam ) throws Exception{
        return () -> columnArticleService.getTagsArticle(tags,pageParam);
    }

}
